
#include "s3c2440_soc.h"

void timer_init(void)
{
	/* Timer clk = PCLK / {prescaler value+1} / {divider value}
	 *			 = 50000000/(99+1)/16
	 *			 = 31250
	 */
	TCFG0 = 99;
	TCFG1 &= ~0xf;
	TCFG1 |= (3<<0);

	TCNTB0 = 15625;

	TCON |= (1<<1);

	TCON &= ~(1<<1);
	TCON |= ((1<<3) | (1<<0));
}

void timer_handle_irq(void)
{
	static int val = 0;
	int temp;

	temp = ~val;
	temp &= 7;
	GPFDAT &= ~(7<<4);
	GPFDAT |=  (temp<<4);
	val++;
}

